home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 18553 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: lyra.csx.cam.ac.uk!lhkc100
  2. From: lhkc100@thor.cam.ac.uk (L.H.K. Chan)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: How to read: operator overloaded <<
  5. Date: 21 Apr 1996 14:33:27 GMT
  6. Organization: University of Cambridge, England
  7. Message-ID: <4ldgvn$skv@lyra.csx.cam.ac.uk>
  8. References: <4ldfpc$j0u@amanda.dorsai.org>
  9. NNTP-Posting-Host: hammer.thor.cam.ac.uk
  10.  
  11. In article <4ldfpc$j0u@amanda.dorsai.org>, mongoose@dorsai.org (Jeff Yu) writes:
  12. |> Hi, I have hard time to understand the syntac of << operator overloaded 
  13. |> declaration. As it is stated in Lippman's C++ Primer, the << sample is
  14. |> supposed to take TWO parameters: ostream& operator<<(ostream& os, String& s)
  15. |> But when using it, the way is: cout<<"test"<<MyScreen<<endl;
  16. |> Where is the second parameter if I consider the MyScreen as the first one?
  17.  
  18. Think about it in this way,
  19.  
  20. << ( << ( << (cout, "test"), MyScreen), endl);
  21.  
  22. That is, instead of thinking it as an infix operator, think about it as prefix
  23. operator!  Is that clear?
  24.  
  25. Regards,
  26.  
  27. Kelvin 
  28.  
  29. |> 
  30. |> What is the difference from ostream& operator << (String &s)?
  31. |> 
  32. |> Please help!
  33. |> 
  34.